package org.javaboy.vhr.utils;

import org.springframework.stereotype.Component;

@Component
public class IdGeneratorUtils {
	
	public static  String getId(String idKey) {
		Object idString = IdGenerator.redis.opsForValue().get(idKey);
		if(null==idString) {
			idString =0;
		}
		Integer newValue = Integer.valueOf(idString.toString())+1;
		IdGenerator.redis.opsForValue().set(idKey, newValue);
		//设置指定key，移除过期属性。
		IdGenerator.redis.persist(idKey);
		String timestamp = DateUtils.getTimeStampString();
		//字符串格式化,数字类型左边补0至10位数。
		String endStr = String.format("%010d", newValue);
		return timestamp+endStr;
	}
	
	
}
